﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PServiceBus.Core.Security;
using PServiceBus.Gateway.Interfaces;
using PServiceBus.Gateway.Interfaces.DTO;
using Phoenix.RedisConnectors;

namespace PServiceBus.Gateway.Redis.DTO {
    public class RedisESBRequest : ESBRequest, IRedisCommand {

        #region IRedisCommand Members

        public bool IsAsync { get; set; }

        public string Key { get; set; }

        public RedisPatternType Pattern { get; set; }

        public string CommandID { get; set; }

        #endregion
        public static RedisESBRequest New(string input = "", ESBIdentity userIdentity = null, bool reThrowException = false, Dictionary<string, string> headers = null) {
            var identity = userIdentity ?? ESBPrincipal.Current.ESBIdentity;
            return new RedisESBRequest()
            {
                Input = input,
                UserContext = new ESBUserContext() {
                    UserName = identity.Name,
                    Password = identity.Password
                }, ReThrowException = reThrowException,
                Headers = headers
            };
        }
        public static RedisESBRequest Empty {
            get { return New(string.Empty); }
        }
    }
}
